﻿@using ThuySan.Areas.Backend.Models
@model IEnumerable<dynamic>
@{
    Layout = "~/Areas/Backend/Views/Shared/_Layout.cshtml";
    Header header = new Header {
                                       Common = "ViewUserControl_Property_Index",
                                       CurentCommon = "Property",
                                       PageHeader = "Manage Property",
                                       Menulv1 = "01",
                                       Menulv2 = "0103"
                               };
    ViewData[Header.Key] = header;
    ViewBag.Title = "Manage Property - Admin Control Panel";
}
@(Html.Telerik().Grid(Model).Name("grid").Columns(c =>
                                                      {
                                                          c.Bound(typeof(int), "PropertyId").Title("#").Width(50);
                                                          c.Bound(typeof(string), "Name");
                                                          c.Bound(typeof(string), "GroupName");
                                                          c.Bound("IsBit").Filterable(false).ClientTemplate("<input <#= IsBit #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsNumber").Filterable(false).ClientTemplate("<input <#= IsNumber #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Template(v => v.ProductId).ClientTemplate(Html.ActionLink("<span class=\"t-icon t-edit\"></span>", "Edit", new
                                                          {
                                                              id = "<#=PropertyId#>"
                                                          }, new
                                                          {
                                                              @class = "t-button t-button-icon t-grid-edit",
                                                          }).ToHtmlString() + "<a class=\"t-button t-button-icon t-grid-delete\" href=\"javascript:Delete(<#=PropertyId#>);\"><span class=\"t-icon t-delete\"></span></a>").Width(80);
                                                      }).Sortable(c => c.Enabled(true)).Filterable().DataKeys(c => c.Add("PropertyId")).Pageable(c =>
                                                                                                                                       {
                                                                                                                                           c.Enabled(true);
                                                                                                                                           c.PageSize(25);
                                                                                                                                       }).DataBinding(c => c.Ajax().Select("GetList", "Property")))
@section script
{
    <script type="text/javascript">
        function Delete(id) {
            if (confirm("Do you want to delete?"))
                $.post('@Url.Action("Delete", "Property")', { id: id }, function () {
                    $("#grid").data("tGrid").ajaxRequest();
                });
        }
    </script>
}
 